package de.hauschild.gmltracer.tracer.impl;

import java.util.List;

import org.apache.commons.math.geometry.Vector3D;

import de.hauschild.gmltracer.tracer.Light;
import de.hauschild.gmltracer.tracer.Ray;
import de.hauschild.gmltracer.tracer.RayRenderer;
import de.hauschild.gmltracer.tracer.Shape;

/**
 * An abstract implementation of {@link RayRenderer} providing basic functionality for render recursion.
 * 
 * @since 1.0.0
 * @author Klaus Hauschild
 */
public abstract class AbstractRayRenderer implements RayRenderer {

  @Override
  public Vector3D renderRay(final Ray ray, final Shape scene, final Vector3D ambientLightIntensity,
      final List<Light> lights, final int tracingDepth, final int currentTracingDepth) {
    // tracing depth achieved
    if (currentTracingDepth > tracingDepth) {
      return Vector3D.zero;
    }
    // recursive rendering
    return renderRayRecursive(ray, scene, ambientLightIntensity, lights, tracingDepth, currentTracingDepth);
  }

  protected abstract Vector3D renderRayRecursive(final Ray ray, final Shape scene,
      final Vector3D ambientLightIntensity, final List<Light> lights, final int tracingDepth,
      final int currentTracingDepth);
}
